libxl: Prevent qemu closing QMP socket on shutdown before libxl is done with it.
authorSander Eikelenboom <linux@eikelenboom.it>
Thu, 22 Jan 2015 17:21:40 +0000 (18:21 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 27 Jan 2015 16:45:29 +0000 (16:45 +0000)
commit9ba80a722b193c912432d544338f8daf9a846cd7
tree888f44cd09cf44bf505b0e32511ab21d8428237c
parent296c7f3284efe655d95a8ae045a5dc1a20d6fff0
libxl: Prevent qemu closing QMP socket on shutdown before libxl is done with it.

At present on shutdown when using pci-passthrough with qemu-xen, qemu
closes the QMP socket before libxl is done with it causing these
errors to be logged by libxl:

    Waiting for domain test (domid 1) to die [pid 11568]
    Domain 1 has shut down, reason code 0 0x0
    Action for shutdown reason code 0 is destroy
    Domain 1 needs to be cleaned up: destroying the domain
    libxl: error: libxl_qmp.c:443:qmp_next: Socket read error: Connection reset by peer
    libxl: error: libxl_qmp.c:701:libxl__qmp_initialize: Failed to connect to QMP
    libxl: error: libxl_qmp.c:686:libxl__qmp_initialize: Connection error: Connection refused
    libxl: error: libxl_dm.c:1588:kill_device_model: Device Model already exited
    Done. Exiting now

Prevent this by using the qemu '-no-shutdown' parameter which is
described as doing:

    "Don’t exit QEMU on guest shutdown, but instead only stop the emulation.
     This allows for instance switching to monitor to commit changes to the disk image."

So Qemu will stop emulating, but keeps the QMP socket open and waits
for libxl to kill the qemu process when it is done, preventing the
race and resulting in this to be logged by libxl:

    Waiting for domain test (domid 1) to die [pid 10859]
    Domain 1 has shut down, reason code 0 0x0
    Action for shutdown reason code 0 is destroy
    Domain 1 needs to be cleaned up: destroying the domain
    Done. Exiting now

Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/libxl_dm.c